﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.Data;
using KPIS.GERP.GHRMS.DAL;
using KPIS.GERP.GHRMS.MODEL;
using KPIS.GERP.GHRMS.IBLL;
using KPIS.GERP.GHRMS.IDAL;
using KPIS.GERP.GHRMS.DALFactory;

namespace KPIS.GERP.GHRMS.BLL
{
    public sealed class MovmentBLL : IMovmentBLL
    {
        private static readonly IMovmentDAL DAL = DataAccess.CreateMovments();

        private MovmentInfo movInfo = new MovmentInfo();
        private EmployeeTypeInfo etInfo = new EmployeeTypeInfo();

        public IList<MovmentInfo> ListMovments(string EmployeeType)
        {
            if (EmployeeType.Length > 0)
                etInfo.Sequence = Int32.Parse(EmployeeType);
            movInfo.EmployeeType = etInfo;

            return DAL.ListMovments(movInfo);
        }
        public IList<MovmentInfo> ListMovmentsBySequence(int Sequence)
        {
            return DAL.ListMovments(new MovmentInfo(Sequence));
        }

        public void Insert(string EmployeeType, string Code, string Name, string Type, string Remarks, int CreatedBy)
        {
            if (EmployeeType.Length > 0)
                etInfo.Sequence = Int32.Parse(EmployeeType);

            try
            {
                DAL.Insert(new MovmentInfo(0, etInfo, Code, Name, Type, Remarks, "", CreatedBy, 0));
            }
            catch
            {
                throw new Exception("");
            }
        }
        public void Update(int Sequence, string EmployeeType, string Code, string Name, string Type
            , string Remarks, string RecordStatus, int UpdatedBy)
        {
            if (EmployeeType.Length > 0)
                etInfo.Sequence = Int32.Parse(EmployeeType);

            try
            {
                DAL.Update(new MovmentInfo(Sequence, etInfo, Code, Name, Type, Remarks, RecordStatus, 0, UpdatedBy));
            }
            catch
            {
                throw new Exception("");
            }
        }
        public void Delete(int Sequence, int UpdatedBy)
        {
            try
            {
                DAL.Delete(Sequence, UpdatedBy);
            }
            catch
            {
                throw new Exception("");
            }
        }
    }
}
